<template>
  <div>
    <!-- 标题 -->
    <div class="talentsTop">
      <h2 class="title">{{title}}</h2>
      <div class="more" @click="moreTalents"><span>查看更多</span></div>
    </div>
    <!-- 轮播 -->
    <div class="contentSwiper">
      <swiper
        ref="mySwiper"
        :options="swiperOptions"
        class="content"
        autoplay="true"
      >
        <swiper-slide v-for="item in talentsData" :key="item.id">
          <div class="talents-item" @click="TalDetails(item)">
            <div class="img">
              <img :src="item.url" alt="" />
            </div>
            <div class="message">
              <p class="uname">{{item.uname}}</p>
              <p class="occupa">{{item.word}}</p>
            </div>
          </div>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
    <!-- 大图 -->
    <div class="bigImg">
      <img :src="imgUrl" alt="" />
    </div>
  </div>
</template>

<script>
import api from '../../api'
export default {
  name: "HomeTalents",
  data() {
    return {
      talentsData:[],
      title:'',
      imgUrl:'',
      swiperOptions: {
        slidesPerView: 2.5,
        spaceBetween: 10,
      },
    };
  },
  methods:{
    moreTalents(){
      this.$router.push('/talents')
    },
    TalDetails(id){
      this.$router.push(
        {
          name:'TalentsDetails',
          params:{
            id:id
          }
        }
      )
    }
  },
  mounted(){
    api.getTalents().then(res=>{
      // console.log(res.data);
      this.title = res.data.title
      this.imgUrl = res.data.imgUrl
      this.talentsData = res.data.list
    })
  }
};
</script>

<style lang="less" scoped>
.talentsTop {
  width: 100%;
  height: 26px;
  line-height: 26px;
  padding: 12px 0;
  .title {
    float: left;
    margin-left: 10px;
    width: 73px;
    height: 26px;
    line-height: 26px;
    color: rgba(51, 51, 51, 1);
    font-size: 18px;
    text-align: center;
    font-family: Arial;
  }
  .more {
    float: right;
    margin-right: 10px;
    width: 49px;
    height: 23px;
    line-height: 17px;
    color: rgba(153, 153, 153, 1);
    font-size: 12px;
    text-align: center;
    font-family: Arial;
  }
}
// 轮播图
.contentSwiper {
  width: 100%;
  height: 252px;
  padding-left: 10px;
  box-sizing: border-box;
}
.talents-item {
  width: 132px;
  height: 252px;
  .img {
    width: 132px;
    height: 177px;
    margin: 11px 0;
    img {
      width: 100%;
      height: 100%;
      border-radius: 8px;
    }
  }
  .message {
      width: 100%;
      text-align: center;
    .uname {
      height: 23px;
      color: rgba(16, 16, 16, 1);
      font-size: 16px;
      text-align: center;
    }
    .occupa {
      height: 23px;
      color: rgba(153, 153, 153, 1);
      font-size: 12px;
    }
  }
}
// 大图
.bigImg {
  width: 100%;
  height: 94px;
  padding: 5px 0;
  background-color: #eee;
  img {
    width: 100%;
    height: 100%;
  }
}
</style>